from toee import *
from utilities import *
from InventoryRespawn import *

def san_dialog( attachee, triggerer ):
	if ( game.quests[11].state != qs_botched and game.global_vars[996] == 0):
		triggerer.begin_dialog( attachee, 1 )
	elif ( game.global_vars[996] == 2 and game.quests[90].state == qs_unknown):
		triggerer.begin_dialog( attachee, 210 )
	elif ( game.global_vars[996] == 2 and game.quests[90].state != qs_unknown):
		triggerer.begin_dialog( attachee, 280 )
	else:
		triggerer.begin_dialog( attachee, 30 )
	return SKIP_DEFAULT

def san_first_heartbeat(attachee, triggerer):
	game.timevent_add(respawn, (attachee), 86400000 ) #86400000ms is 24 hours
	game.new_sid = 0
	return RUN_DEFAULT

def	san_spell_cast( attachee, triggerer, spell ):
	if ( spell.spell == spell_heal ):
		if ( game.quests[11].state == qs_mentioned or game.quests[11].state == qs_accepted ):
			game.global_vars[996] = 1
			triggerer.begin_dialog( attachee, 60 )
		else:
			game.quests[11].state = qs_botched
			game.global_vars[996] = 2
			triggerer.begin_dialog( attachee, 70 )
	return RUN_DEFAULT

def master( attachee, triggerer ):
	game.global_vars[996] = 3
	npc = find_container_near(attachee,1001)
	#npc.obj_set_int( obj_f_container_inventory_source, 342 )
	game.timevent_add( RespawnInventory, ( npc, 342 ), 604800000 ) #604800000ms is 1 week
	game.timevent_add( will_sell, ( attachee, ), 604800000 ) #604800000ms is 1 week
	return RUN_DEFAULT

def will_sell( attachee ):
	game.global_vars[996] = 4
	return RUN_DEFAULT